﻿Module modProjectData


    Public Sub InsertTank(ByVal TankName As String, ByVal TankWeight As Double)
        ExecuteSQL("INSERT INTO [Tanks] (TankName, TankWeight) values ('" & TankName & "', '" & TankWeight & "')")
    End Sub


    Public Sub InsertBatch(ByVal BatchName As String, ByVal BatchCode As Integer)
        ExecuteSQL("INSERT INTO [Batchs] (BatchName, BatchCode) values ('" & BatchName & "', '" & BatchCode & "')")
    End Sub


    Public Sub InsertBatchDetail(ByVal BatchID As Integer, ByVal TankID As Integer, ByVal MixWeight As Double, ByVal LowSpeed As Double,
                                 ByVal HighSpeed As Double, ByVal LowWeight As Double, ByVal HighWeight As Double, ByVal FreeFallWeight As Double)
        ExecuteSQL("INSERT INTO [BatchsDetails] (BatchID, TankID, MixWeight, LowSpeed, HighSpeed, LowWeight, HighWeight, FreeFallWeight) values ('" & BatchID & "', '" & TankID & "', '" & MixWeight & "', '" & LowSpeed & "', '" & HighSpeed & "', '" & LowWeight & "', '" & HighWeight & "', '" & FreeFallWeight & "')")
    End Sub


    Public Function InsertBatchRecord(ByVal BatchID As Integer, ByVal TotalWeight As Double, ByVal Dat As DateTime) As Integer
        ExecuteSQL("INSERT INTO [BatchRecords] (BatchID, TotalWeight, Date) values ('" & BatchID & "', '" & TotalWeight & "', '" & Dat & "')")
        Return GetMax("BatchRecords", "RecordID")
    End Function

    Public Sub UpdateBatchRecord(ByVal RecordID As Integer, ByVal TotalWeight As Double)
        ExecuteSQL(String.Format("Update [BatchRecords] SET TotalWeight = {0} WHERE RecordID = {1}", TotalWeight, RecordID))
    End Sub


    Public Sub InsertBatchRecordDetail(ByVal RecordID As Integer, ByVal TankID As Integer, ByVal MixWeight As Double)
        ExecuteSQL("INSERT INTO [BatchRecordsDetails] (RecordID , TankID, MixWeight) values ('" & RecordID & "', '" & TankID & "', '" & MixWeight & "')")
    End Sub


    Public Sub InsertAlarm(ByVal AlarmUnit As String, ByVal AlarmDesc As String, ByVal AlarmDate As DateTime, ByVal BatchID As Integer)
        ExecuteSQL("INSERT INTO [Alarms] (Alarm_Unit , Alarm_Desc, Alarm_Date, BatchID) values ('" & AlarmUnit & "', '" & AlarmDesc & "', '" & AlarmDate & "', '" & BatchID & "')")
    End Sub

    Public Sub InsertBatchFinal(ByVal BatchName As String, ByVal Tank1 As Double, ByVal Tank2 As Double, ByVal Tank3 As Double, ByVal Tank4 As Double, ByVal Tank5 As Double, ByVal Tank6 As Double, ByVal Tank7 As Double, ByVal Tank8 As Double, ByVal Tank9 As Double, ByVal Tank10 As Double, ByVal Tank11 As Double, ByVal Tank12 As Double, ByVal Tanks As Double, ByVal DateTime As DateTime)
        ExecuteSQL("INSERT INTO [BatchFinal] (BatchName , Tank1, Tank2, Tank3, Tank4, Tank5, Tank6, Tank7, Tank8, Tank9, Tank10, Tank11, Tank12, Tanks, DateTime) values ('" & BatchName & "', '" & Tank1 & "', '" & Tank2 & "', '" & Tank3 & "', '" & Tank4 & "', '" & Tank5 & "', '" & Tank6 & "', '" & Tank7 & "', '" & Tank8 & "', '" & Tank9 & "', '" & Tank10 & "', '" & Tank11 & "', '" & Tank12 & "', '" & Tanks & "', '" & DateTime & "')")
    End Sub


    '' '' '' '' '' ''-
    ' '' ''Public Sub InsertNewBatch(ByVal name_batch As String, ByVal code_batch As Integer, ByVal corn1 As Double, ByVal w_h_corn1 As Double,
    ' '' ''                            ByVal sp_h_corn1 As Integer, ByVal w_l_corn1 As Double, ByVal sp_l_corn1 As Integer, ByVal w_f_corn1 As Double,
    ' '' ''                            ByVal corn2 As Double, ByVal w_h_corn2 As Double,
    ' '' ''                            ByVal sp_h_corn2 As Integer, ByVal w_l_corn2 As Double, ByVal sp_l_corn2 As Integer, ByVal w_f_corn2 As Double,
    ' '' ''                            ByVal soy1 As Double, ByVal w_h_soy1 As Double,
    ' '' ''                            ByVal sp_h_soy1 As Integer, ByVal w_l_soy1 As Double, ByVal sp_l_soy1 As Integer, ByVal w_f_soy1 As Double,
    ' '' ''                            ByVal soy2 As Double, ByVal w_h_soy2 As Double,
    ' '' ''                            ByVal sp_h_soy2 As Integer, ByVal w_l_soy2 As Double, ByVal sp_l_soy2 As Integer, ByVal w_f_soy2 As Double,
    ' '' ''                            ByVal sn As Double, ByVal w_h_sn As Double,
    ' '' ''                            ByVal sp_h_sn As Integer, ByVal w_l_sn As Double, ByVal sp_l_sn As Integer, ByVal w_f_sn As Double,
    ' '' ''                            ByVal rada As Double, ByVal w_h_rada As Double,
    ' '' ''                            ByVal sp_h_rada As Integer, ByVal w_l_rada As Double, ByVal sp_l_rada As Integer, ByVal w_f_rada As Double,
    ' '' ''                            ByVal con As Double, ByVal w_h_con As Double,
    ' '' ''                            ByVal sp_h_con As Integer, ByVal w_l_con As Double, ByVal sp_l_con As Integer, ByVal w_f_con As Double,
    ' '' ''                            ByVal gelotine As Double, ByVal w_h_gelotine As Double,
    ' '' ''                            ByVal sp_h_gelotine As Integer, ByVal w_l_gelotine As Double, ByVal sp_l_gelotine As Integer, ByVal w_f_gelotine As Double,
    ' '' ''                            ByVal oil As Double, ByVal w_h_oil As Double,
    ' '' ''                            ByVal sp_h_oil As Integer, ByVal w_l_oil As Double, ByVal sp_l_oil As Integer, ByVal w_f_oil As Double,
    ' '' ''                            ByVal [add] As Double, ByVal w_h_add As Double,
    ' '' ''                            ByVal sp_h_add As Integer, ByVal w_l_add As Double, ByVal sp_l_add As Integer, ByVal w_f_add As Double,
    ' '' ''                            ByVal ex1 As Double, ByVal w_h_ex1 As Double,
    ' '' ''                            ByVal sp_h_ex1 As Integer, ByVal w_l_ex1 As Double, ByVal sp_l_ex1 As Integer, ByVal w_f_ex1 As Double,
    ' '' ''                            ByVal ex2 As Double, ByVal w_h_ex2 As Double,
    ' '' ''                            ByVal sp_h_ex2 As Integer, ByVal w_l_ex2 As Double, ByVal sp_l_ex2 As Integer, ByVal w_f_ex2 As Double)
    ' '' ''    ExecuteSQL("INSERT INTO [BatchsDetails] (name_batch, code_batch, corn1, w_h_corn1, w_l_corn1, sp_l_corn1, w_f_corn1, corn2,w_h_corn2 ,sp_h_corn2 ,w_l_corn2 ,sp_l_corn2 ,w_f_corn2 ,soy1 ,w_h_soy1 ,sp_h_soy1 ,w_l_soy1 ,sp_l_soy1 ,w_f_soy1 ,soy2 ,w_h_soy2 ,sp_h_soy2 ,w_l_soy2 ,sp_l_soy2 ,w_f_soy2 ,sn ,w_h_sn ,sp_h_sn ,w_l_sn ,sp_l_sn ,w_f_sn ,rada ,w_h_rada ,sp_h_rada , w_l_rada, ,sp_l_rada ,w_f_rada ,con ,w_h_con ,sp_h_con ,w_l_con ,sp_l_con ,w_f_con ,gelotine ,w_h_gelotine ,sp_h_gelotine ,w_l_gelotine ,sp_l_gelotine ,w_f_gelotine ,oil ,w_h_oil ,sp_h_oil ,w_l_oil ,sp_l_oil ,w_f_oil ,[add] ,w_h_add ,sp_h_add , w_l_add, sp_l_add,w_f_add , ex1, w_h_ex1, sp_h_ex1, w_l_ex1, sp_l_ex1, w_f_ex1, ex2, w_h_ex2, sp_h_ex2, w_l_ex2, sp_l_ex2,w_f_ex2 ) values ('" & name_batch & "', '" & code_batch & "', '" & corn1 & "', '" & w_h_corn1 & "', '" & w_l_corn1 & "', '" & sp_l_corn1 & "', '" & w_f_corn1 & "', '" & corn2 & "', '" & w_h_corn2 & "' , '" & sp_h_corn2 & "' , '" & w_l_corn2 & "' , '" & sp_l_corn2 & "' , '" & w_f_corn2 & "' , '" & soy1 & "' , '" & w_h_soy1 & "' , '" & sp_h_soy1 & "' , '" & w_l_soy1 & "' , '" & sp_l_soy1 & "' , '" & w_f_soy1 & "' , '" & soy2 & "' , '" & w_h_soy2 & "' , '" & sp_h_soy2 & "' , '" & w_l_soy2 & "' , '" & sp_l_soy2 & "' , '" & w_f_soy2 & "' , '" & sn & "', '" & w_h_sn & "' ,'" & sp_h_sn & "' , '" & w_l_sn & "' , '" & sp_l_sn & "' , '" & w_f_sn & "' , '" & rada & "' , '" & w_h_rada & "' , '" & sp_h_rada & "' , '" & w_l_rada & "' , '" & sp_l_rada & "' ,'" & w_f_rada & "' , '" & con & "' , '" & w_h_con & "' , '" & sp_h_con & "' , '" & w_l_con & "' , '" & sp_l_con & "' , '" & w_f_con & "' , '" & gelotine & "' , '" & w_h_gelotine & "' , '" & sp_h_gelotine & "' , '" & w_l_gelotine & "' , '" & sp_l_gelotine & "' , '" & w_f_gelotine & "' , '" & oil & "' , '" & w_h_oil & "' , '" & sp_h_oil & "' , '" & w_l_oil & "' , '" & sp_l_oil & "' , '" & w_f_oil & "' , '" & [add] & "' , '" & w_h_add & "' , '" & sp_h_add & "' , '" & w_l_add & "', '" & sp_l_add & "', '" & w_f_add & "' , '" & ex1 & "', '" & w_h_ex1 & "', '" & sp_h_ex1 & "', '" & w_l_ex1 & "', '" & sp_l_ex1 & "', '" & w_f_ex1 & "', '" & ex2 & "', '" & w_h_ex2 & "', '" & sp_h_ex2 & "', '" & w_l_ex2 & "', '" & sp_l_ex2 & "', '" & w_f_ex2 & "' )")
    ' ''End Sub
End Module
